# 7-1 回文素数【函数】
import math
def is_prime(n):
    # if x == 1:
    #     return False
    # for i in range(2, x):
    #     if x % i == 0:
    #         return False
    #         break
    # else:
    #     return True

    if n <= 1:
        return False
    if n <= 3:
        return True
    if n % 2 == 0 or n % 3 == 0:
        return False
    for i in range(5, int(math.sqrt(n)) + 1, 6):
        if n % i == 0 or n % (i + 2) == 0:
            return False
    return True

def isPalindromic(x):
    x=str(x)
    if x == x[::-1]:
        return True
    return False


def palindromic_prime():
    n = int(input())
    queue = []
    count = 0
    i = 1
    while count < n:
        if is_prime(i) and isPalindromic(i):
            count += 1
            queue.append(i)
        i += 1
    for s in queue:
        print(s,end=" ")


# palindromic_prime()